<?php
if (!isset($_POST['EMAIL'])) {
    header("Location: successful.php?code=1&message=EMAIL is EMPTY");
} else if (!isset($_POST['FIRST_NAME'])) {
    header("Location: successful.php?code=1&message=FIRST_NAME is EMPTY");
} else if (!isset($_POST['SURNAME'])) {
    header("Location: successful.php?code=1&message=SURNAME is EMPTY");
} else if (!isset($_POST['PASSWORD'])) {
    header("Location: successful.php?code=1&message=PASSWORD is EMPTY");
} else if (!isset($_FILES['PHOTO_URL'])) {
    header("Location: successful.php?code=1&message=PHOTO is EMPTY");
} else {
    include_once 'connect_DB.php';
    $FIRST_NAME = $_POST['FIRST_NAME'];
    $SURNAME = $_POST['SURNAME'];
    $PASSWORD = $_POST['PASSWORD'];
    $EMAIL = $_POST['FIRST_NAME'];
    $PHOTO_URL = $_FILES['PHOTO_URL']['name'];
    echo $FIRST_NAME . $SURNAME . $PASSWORD . $EMAIL . $PHOTO_URL;
    move_uploaded_file($_FILES['PHOTO_URL']['tmp_name'], 'img/' . $_FILES['PHOTO_URL']['name']);
    $query = mysqli_query($con, "INSERT INTO `user_db` (`EMAIL`, `FIRST_NAME`, `SURNAME`, `PASSWORD`, `PHOTO_URL`) VALUES ('$EMAIL', '$FIRST_NAME', '$SURNAME','$PASSWORD', '$PHOTO_URL')");
    if (mysqli_errno($con) != 0) {
        header("Location: successful.php?code=1&message=" . mysqli_error($con));
    } else {
        header("Location: successful.php?code=0");
    }
}